home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / WINER.ZIP / CHAP6-4.BAS < prev    next >
BASIC Source File  |  1992-05-13  |  1KB  |  53 lines

  1. '*********** CHAP6-4.BAS - simple text file browser
  2.  
  3. 'Copyright (c) 1992 Ethan Winer
  4.  
  5. DEFINT A-Z
  6.  
  7. CONST MaxLines% = 5000
  8. REDIM Offset&(1 TO MaxLines%)
  9.  
  10. CLS
  11. PRINT "Enter the name of file to browse: ";
  12. LINE INPUT "", FileName$
  13.  
  14. OPEN FileName$ FOR INPUT AS #1
  15.  
  16.   Offset&(1) = 1                'initialize to offset 1
  17.   CurLine = 1                   'and start with line 1
  18.  
  19.   WHILE Action$ <> CHR$(27)     'until they press Escape
  20.     SEEK #1, Offset&(CurLine)   'seek to the current line
  21.     LINE INPUT #1, Text$        'read that line
  22.     Offset&(CurLine + 1) = SEEK(1)  'save where the next
  23.                                     '  line starts
  24.     CLS
  25.     IF LEN(Text$) THEN          'if it's not blank
  26.       PRINT Text$               'print the line
  27.     ELSE                        'otherwise
  28.       PRINT "(blank line)"      'show that it's blank
  29.     END IF
  30.  
  31.     DO                          'wait for a key
  32.       Action$ = INKEY$
  33.     LOOP UNTIL LEN(Action$)
  34.  
  35.     SELECT CASE ASC(RIGHT$(Action$, 1))
  36.       CASE 71                   'Home
  37.         CurLine = 1
  38.  
  39.       CASE 72                   'Up arrow
  40.         IF CurLine > 1 THEN
  41.           CurLine = CurLine - 1
  42.         END IF
  43.  
  44.       CASE 80                   'Down arrow
  45.         IF (NOT EOF(1)) AND CurLine < MaxLines% THEN
  46.           CurLine = CurLine + 1
  47.         END IF
  48.  
  49.       CASE ELSE
  50.     END SELECT
  51.   WEND
  52. CLOSE
  53.